﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;

public partial class Test_KillWord : BasePage
{
    private void Page_Load(object sender, System.EventArgs e)
    {
        string processName = "WINWORD";
        //foreach (Process process in System.Diagnostics.Process.GetProcesses())
        //{
        //    if (process.ProcessName.ToLower().CompareTo(processName.ToLower()) == 0)
        //    {
        //        process.Kill();
        //    }
        //}
        //KillAcrodist();

        //定义进程
        System.Diagnostics.Process myproc = new System.Diagnostics.Process();
        //获取选择的进程名称
        string proname = processName;
        //从所有的进程中获取选择的进程
        //foreach (Process pro in Process.GetProcessesByName(proname))
        foreach (Process pro in Process.GetProcesses())
        {
            //Response.Write(pro.Id + " " + pro.ProcessName + " selected<br />");
            //判断是否是系统的主要进程，如果是则不能结束
            if (!pro.CloseMainWindow() && pro.ProcessName.ToLower() == processName.ToLower())
            {
                //lblMsg.Text = this.DropPro.SelectedValue + "进程被结束！";
                //结束进程
                Response.Write(pro.Id + " " + pro.ProcessName + " killed<br />");
                pro.Kill();
            }
        }

        string str2 = "";
        for (int i = 0; i < 1000; i++)
        {
            str2 += "|bddaasdfkjsdlajlsjdfljfsdljsdf|\r\n";
            Response.Write(str2);
            Response.Flush();
            System.Threading.Thread.Sleep(1000);
        }
    }
    /// <summary>
    /// 为防止本方法调用多次时发生错误,必须停止acrodist.exe进程
    /// 参考页面 http://blog.csdn.net/hack8/archive/2009/02/05/3863483.aspx
    /// </summary>
    /// <param name="processName"></param>
    public void KillPrecess(string processName)
    {
    }

}